import os
import json
import pickle

books=dict()
for root,dirs,files in os.walk("books"):
    f=files
    for name in files:
        print(name)
        f = open("books\\"+name)
        content=f.read()
        l=len(content)
        books[name]=l
        f.close()
data = json.dumps(books)
f = open("books\\json_file.txt","w",encoding='utf-8')
f.write(data)
f.close()
with open("books\\data2.pkl", "wb") as f:
    pickle.dump(data, f)



#九九乘法表

import argparse

parser = argparse.ArgumentParser(description='命令行中传入一个数字')
parser.add_argument('integers', type=int, help='传入的数字')
args = parser.parse_args()
num = args.integers

def printmul(num):
    i=1
    while(i<num+1):
        j=1
        while (j<=i):
            print("{}*{}={}".format(j,i,i*j),end=" ")
            j=j+1
        print("\n")
        i=i+1
printmul(num)
```
### 课后作业
```
import argparse
import os
import re

parser = argparse.ArgumentParser(description='命令行中传入文件名')
parser.add_argument('name', type=str, help='传入的文件名')
args = parser.parse_args()
name = args.name

try:
    f = open("books\\"+name)
    content=f.read()
    data1 = re.compile(r'[\u0061-\u007a,\u0020-\u003f]')
    en = "".join(data1.findall(content.lower()))
    data2 = re.compile(r'[\u4e00-\u9fa5,\u00d7,\u2013,\u2014,\u2018-\u2027,\u3001,\u3002,\u3003,\u3008-\u3011,\u3014,\u3015,\uff01-\uff0f,\uff1a-\uff20,\uff3b-\uff40,\uff5b-\uff65,\uffe5]')
    cn = "".join(data2.findall(content.lower()))
    f.close()
    f = open("books\\a_EN.txt","w",encoding='utf-8')
    f.write(en)
    f.close()
    f = open("books\\a_CN.txt","w",encoding='utf-8')
    f.write(cn)
    f.close()
except:
    print("文件名错误")
```